package org.acghub.common;

import java.util.Map;

/**
 * @Project demos
 * @Package org.acghub.common
 * @Desc
 * @Author Administrator
 * @Date 2025/7/9/星期三 19:28
 * @Version 1.0
 */
public class Pair<K, V> implements Map.Entry<K, V> {
    private K key;
    private V value;

    public Pair(K key, V value) {
        this.key = key;
        this.value = value;
    }

    public static <K, V> Pair<K, V> of(K key, V value) {
        return new Pair<>(key, value);
    }

    @Override
    public K getKey() {
        return key;
    }

    public void setKey(K key) {
        this.key = key;
    }

    @Override
    public V getValue() {
        return value;
    }

    @Override
    public V setValue(V value) {
        V origin = this.value;
        this.value = value;
        return origin;
    }

    public K left() {
        return key;
    }

    public V right() {
        return value;
    }

    public void left(K key) {
        this.key = key;
    }

    public void right(V value) {
        this.value = value;
    }

}
